<script setup>
  import useHomeStore from '@/stores/modules/home'
  import { storeToRefs } from 'pinia'

  const homeStore = useHomeStore()
  const { categories } = storeToRefs(homeStore)
</script>

<template>
  <div class="categories">
    <template v-for="(item, index) in categories" :key="item.id">
      <div class="item">
        <img :src="item.pictureUrl" alt="">
        <div>{{ item.title }}</div>
      </div>
    </template>
  </div>
</template>

<style lang="less" scoped>
  .categories {
    display: flex;
    overflow-x: auto;
    height: 80px;
    padding: 0 10px;
    margin-top: 8px;
    // 隐藏当前元素的滚动条（移动端专用）
    &::-webkit-scrollbar {
      display: none;
    }

    .item {
      // 默认值为 1：启用压缩 => 设置宽度不生效
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 70px;

      img {
        width: 32px;
        height: 32px;
      }
    }
  }
</style>